package com.example.hospital_208.service.impl;

import com.example.hospital_208.dao.UserDao;
import com.example.hospital_208.po.Doctor;
import com.example.hospital_208.po.User;
import com.example.hospital_208.service.UserService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    private final UserDao userDao;

    public UserServiceImpl(UserDao userDao) {
        this.userDao = userDao;
    }

    @Override
    public List<User> listUsers() {
        return userDao.findAllUsers();
    }

    @Override
    public User getUserById(Integer user_id) {
        return userDao.findUserById(user_id);
    }

    @Override
    public User getUserByUsername(String user_name) {
        return userDao.findUserByUsername(user_name);
    }

    @Override
    public int addUser(User user) {
        return userDao.insertUser(user);
    }

    @Override
    public int updateUser(User user) {
        return userDao.updateUser(user);
    }

    @Override
    public int updateLoginStatus(Integer user_id) {
        return userDao.updateLoginStatus(user_id);
    }

    @Override
    public int deleteUser(Integer user_id) {
        return userDao.deleteUserById(user_id);
    }

    @Override
    public int updatePassword(Integer user_id, String newPassword) {
        return userDao.updatePassword(user_id, newPassword);
    }

    @Override
    public Doctor getDoctorByUserName(String user_name) {
        return userDao.getDoctorByUserName(user_name);
    }
}